#include "SettingPage.h"

SettingPage::SettingPage(AsyncDBManager* dbManager_):asyncDBManager(dbManager_)
{
	ui.setupUi(this);
	hasUserLogin = false;
	productSettingTab = std::make_shared<ProductSettingTab>(&this->ui, asyncDBManager);
	//deviceSettingTab = std::make_shared<DeviceSettingTab>(this->ui, dbManager, dtControl, vjControl);
	deviceSettingTab = std::make_shared<DeviceSettingTab>(&this->ui, asyncDBManager);
	systemSettingTab = std::make_shared<SystemSettingTab>(&this->ui, asyncDBManager);
	rejectSettingTab = std::make_shared<RejectSettingTab>(&this->ui);
}
void SettingPage::updateCurUserInfo(UserInfo user) {
	curUser = user;
	updateTabsUserInfo(curUser);
	if (!curUser.isValid()) {
		hasUserLogin = false;
	}
	hasUserLogin = true;
}

void SettingPage::updateTabsUserInfo(UserInfo user) {
	productSettingTab->updateCurUserInfo(user);
	deviceSettingTab->updateCurUserInfo(user);
	rejectSettingTab->updateCurUserInfo(user);
	systemSettingTab->updateCurUserInfo(user);
}

void SettingPage::updateHWStatus() {
	deviceSettingTab->updateHWStatus();
}